package workers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import messaging.IMessagingHandler;
import messaging.JMSMessagingConstants;
import messaging.SoftwareDevelopmentMessagingHandler;
import model.Software;
import workerUIs.StepFrame;
import workflow.step.IntegrationStep;

public class IntegrationStepWorker extends AbstractStepSwingWorker {

	public IntegrationStepWorker(StepFrame frame,
			IMessagingHandler<Software> messagingHandler) {
		super(frame, messagingHandler);
	}

	@Override
	protected void doStep(Software software) {
		new IntegrationStep().doStep(this.software);		
	}

	public static void main(String[] args) {
		Logger logger = Logger.getLogger(ArchitectureStepWorker.class.getCanonicalName());
		try {			
			final StepFrame integrationFrame = new StepFrame("Step4: Integration", 1200, 200);
			List<String> integrationInputQueues = new ArrayList<String>();
			integrationInputQueues.add(JMSMessagingConstants.IMPL_OUTPUT_INTEGRATION_INPUT);
			integrationInputQueues.add(JMSMessagingConstants.UI_OUTPUT_INTEGRATION_INPUT);
			List<String> integrationOutputQueues = new ArrayList<String>();
			integrationOutputQueues.add(JMSMessagingConstants.INTEGRATION_OUTPUT_TEST_INPUT);
			final IMessagingHandler<Software> messagingHandler = new SoftwareDevelopmentMessagingHandler(integrationFrame, integrationInputQueues, integrationOutputQueues);
			integrationFrame.getNextButton().addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					new IntegrationStepWorker(integrationFrame, messagingHandler).execute();				
				}
			});
		}
		catch (Exception e) {
			logger.log(Level.SEVERE, "Error during initialization: ", e);
		}
	}

}
